package com.gxa.common.utils;/**
 * @author JunYu
 * @create 2022-10-08--11:11
 */

import com.github.yitter.contract.IdGeneratorOptions;
import com.github.yitter.idgen.YitIdHelper;

/**
 * @program: take-out-project
 *
 * @description:
 *
 * @author: JunYu
 *
 * @create: 2022-10-08 11:11
 **/

public class SnowFlower {

    //1. 构造器私有化
    private SnowFlower(){
        super();
        IdGeneratorOptions options = new IdGeneratorOptions(Short.parseShort("1"));
        YitIdHelper.setIdGenerator(options);
    }
    //在本类内部创建实例
    private final static SnowFlower instance = new SnowFlower();

    //提供对外公有静态方法，返回实例对象
    public static SnowFlower getInstance(){return instance;}

    //获取雪花算法

    public long generateId(){
      return YitIdHelper.nextId();
    }
}
